package Day18;

import java.util.Scanner;

public class Main4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long t = sc.nextLong();
        long[] arr = new long[(int) t];
        for (long i = 0; i < t; i++) {
            arr[(int) i] = sc.nextLong();
        }
        long sum = 0;
        for (long i = 0; i < t; i++) {
            for (long j = 1; j < arr[(int) i]; j++) {
                if (arr[(int) i] % j == 0 && j % 10 != 0 && arr[(int) i] / j % 10 != 0) {
                    sum = j + arr[(int) i] / j;
                    System.out.println(sum);
                    break;
                }
            }
        }
    }
}